package com.gears_software.sxdc.dccx.data.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gears_software.sxdc.dccx.data.model.AddressList;
import com.gears_software.sxdc.dccx.ui.view.CollectListItemView;
import com.gears_software.sxdc.dccx.ui.view.CollectListItemView_;

import java.util.HashMap;
import java.util.List;

/**
 * Created by SunMuran on 2017/8/11.
 */

public class CollectListAdapter extends BaseAdapter{
    Context context;
    private List<AddressList> collectData;

    public CollectListAdapter(Context context, List<AddressList> collectData) {
        this.context = context;
        this.collectData = collectData;
    }

    @Override
    public int getCount() {
        return collectData.size();
    }

    @Override
    public Object getItem(int position) {
        return collectData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CollectListItemView itemView;
        if(convertView==null){
            itemView = CollectListItemView_.build(context);
        }else{
            itemView = (CollectListItemView) convertView;
        }
        itemView.bind(collectData.get(position),position);
        return itemView;
    }
}
